This invention relates to computer sequence control and data handling apparatus for returning control of a computer from a debugging program to a target program without removing the breakpoint instruction inserted in the target program.
On-line debugging facilities are provided in computer installations to permit a computer user to monitor the flow of a target program and, at strategic points in the target program, to check the contents of the computer memory or registers in the computer. A description of typical debugging concepts and techniques is given in chapter 8 of Techniques of Program Structure and Design, Prentice Hall, 1975, by E. Yourdon. A generic term for debugging program packages mentioned in this book is "dynamic debugging technique" or DDT.
A typical DDT monitor provides commands for performing at least the following operations:
1. Interrogate the contents of selected computer registers and memory locations.
2. Modify the contents of selected registers and memory locations.
3. Set "traps" or "brakpoints" in the target program (i.e., the program being debugged) at selected locations in memory, and
4. Branch to any selected location in memory or return to the last breakpoint encountered by the target program.
In general, a DDT monitor is loaded into the computer memory along with the target program or programs to be tested. Execution is started in the DDT monitor resulting in the initialization of computer registers and memory as necessary, the establishment of one or more breakpoints in the target program at selected memory locations, and the transfer of control to the target program.
When a breakpoint is encountered in executing the target program, control is returned to the DDT monitor. Computer registers and memory can then be interrogated and modified and breakpoints can be added to or removed from the target program under control of the user. Control is then transferred from DDT back to the target program -- either to the address of the last target program breakpoint encountered or to a new address in the target program.
A common method of inserting breakpoints in a target program has been to replace the contents of a specified memory location in the target program by a single word trap instruction which, when executed, causes a branch or trap into DDT. Both the trapped instruction, i.e, the instruction formerly at the memory location to be trapped, and the address of that location are stored in a breakpoint table in memory. The number of breakpoints which can be inserted in target programs is limited only by the size of the breakpoint table in memory.
Frequently, after a target program breakpoint has been encountered, the user wishes to resume execution of the target program without removing the breakpoint. When returning from DDT to the target program, it is necessary to execute the trapped instruction without immediately causing another trap. This problem has been handled in several ways in existing DDT programs.
In one method, the content of the breakpoint location in the target program is temporarily replaced with the trapped instruction, an interrupt flag is set which will be detected only after execution of the trapped instruction, and the breakpoint is restored to its location in the target program following detection of the interrupt flag. This approach requires a computer architecture which will permit deferral of interrupts and, further, this approach cannot be used to trap target program instructions which inhibit interrupts or which change interrupt priority.
Another solution to the breakpoint return problem is to execute the trapped instruction from the breakpoint table. In this approach, the trapped instruction is executed directly out of the breakpoint table and a branch is taken to the target program instruction following the breakpoint. When this approach is used, it is necessary to simulate all trapped target program instructions whose behavior is dependent upon the state of the computer's program counter, including, e.g., subroutine call instructions and relative branch instructions. It also is necessary to distinguish among trapped target progam instructions which include multiple words. To accomplish this, an instruction length table in memory must be provided which specifies the number of words in each trapped instruction. When different trapped instructions are added to the breakpoint table, it becomes necessary to add additional simulation routines and/or to modify the instruction length table. Thus, where multiple word instructions are trapped, or where relative branch or subroutine call instructions are trapped, a substantial amount of additional programming effort is required to facilitate return from DDT to the trapped instruction of the target program.